/*
map使用
https://www.bilibili.com/video/BV1gf4y1r79E/?p=16&spm_id_from=pageDriver&vd_source=8bd7b24b38e3e12c558d839b352b32f4
*/
package main

import "fmt"

// 遍历
func info(m map[string]string) { // 传的是引用
	for key, val := range m {
		fmt.Printf("key = %v, val = %v\n", key, val)
	}
	//m["foo"] = "bar"
}

func main() {
	fmt.Println("map")
	myMap := make(map[string]string)
	// 添加
	myMap["China"] = "Beijing"
	myMap["Japan"] = "Tokyo"
	// 遍历
	/*
		for key, val := range myMap {
			fmt.Printf("key = %v, val= %v\n", key, val)
		}
	*/
	fmt.Println("=========================")
	info(myMap)
	// 删除
	delete(myMap, "Japan")
	fmt.Println("=========================")
	info(myMap)
	// 修改
	fmt.Println("=========================")
	myMap["China"] = "Shijiazhuang"
	info(myMap)
}
